local vue = dofile("vue.lua");

local env = {}

-- lua 全局函数
env.print = _G.print;
env.tostring = _G.tostring;
env.type = _G.type;
env.io = _G.io;
env.file = _G.file;
env.math = _G.math;
env.os = _G.os;
env.string = _G.string;
env.table = _G.table;
env.utf8 = _G.utf8;

function NewEnv(window)

end


return setmetatable(env, {
    __index = function(t, k)
        -- 动态全局值
    end,
    __call = function(_, window)
        local G = {}
        -- 自定义全局函数
        G.dofile = dofile;
        G.inhert = commonlib.inherit;
        G.ToolBase = commonlib.gettable("commonlib.ToolBase");
    
        G.vue = setmetatable({}, {__index = vue});
        G.vue.createApp = function(...) return vue.createApp(window, ...) end
        G.addEventListener = function(event_name, callback) window:RegisterEventCallBack(event_name, callback); end
        G.exit = function() window:Close(); end
        G.window = G;

        return setmetatable(G, {__index = env});
    end
});
